const express = require('express');
const db = require('../db/index');  // 导入数据库连接对象
const router = express.Router();

// 获取某个课程和章节的题目
router.get('/getTestQuestion/:courseId/:chapterId', (req, res) => {
    const { courseId, chapterId } = req.params;
    const sql = 'SELECT * FROM question WHERE course_id = ? AND chapter_id = ?';
    db.query(sql, [courseId, chapterId], (err, results) => {
        if (err) {
            return res.status(500).send({ message: '获取题目列表失败', error: err });
        }
        console.log(results)
        res.send(results);
    });
});


module.exports = router;
